/*
 * CcSymbol.c
 *
 *  Created on: 2012/04/28
 *      Author: guanxiaoying
 */
#include "../coredef.h"
#include "../table/table.h"
#include "cc.h"

VOID CcSymInitial(VOID){
	// nothing to do
}
AST CcSymNewMember( PSZ name ){
	AST  astMember=0;
	stSymbolInfoAccess.alloc(1);
	astMember = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astMember, xNAMESPACE_MEM );
	stSymbolInfoAccess.name.set( astMember, name );
	stSymbolInfoAccess.kind.set( astMember, SYMBOL_KIND_MEMBER );
	return astMember;
}
AST CcSymNewParameter( PSZ name ){
	AST  astParam=0;
	stSymbolInfoAccess.alloc(1);
	astParam = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astParam, xNAMESPACE_ARG );
	stSymbolInfoAccess.name.set( astParam, name );
	stSymbolInfoAccess.kind.set( astParam, SYMBOL_KIND_PARAM );
	return astParam;
}
AST CcSymNewLabel( PSZ name ){
	AST  astLabel=0;
	stSymbolInfoAccess.alloc(1);
	astLabel = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astLabel, xNAMESPACE_LABEL );
	stSymbolInfoAccess.name.set( astLabel, name );
	stSymbolInfoAccess.kind.set( astLabel, SYMBOL_KIND_LABEL );
	return astLabel;
}
AST CcSymNewTagName( PSZ name ){
	AST  astTag=0;
	stSymbolInfoAccess.alloc(1);
	astTag = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astTag, xNAMESPACE_TAG );
	stSymbolInfoAccess.name.set( astTag, name );
	stSymbolInfoAccess.kind.set( astTag, SYMBOL_KIND_TAG );
	return astTag;
}
AST CcSymNewTypedefID( PSZ name ){
	AST  astTypedefID=0;
	stSymbolInfoAccess.alloc(1);
	astTypedefID = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astTypedefID, xNAMESPACE_ORD );
	stSymbolInfoAccess.name.set( astTypedefID, name );
	stSymbolInfoAccess.kind.set( astTypedefID, SYMBOL_KIND_TYPEDEFID );
	return astTypedefID;
}
AST CcSymNewEnumConst( PSZ name ){
	AST  astEnumConst=0;
	stSymbolInfoAccess.alloc(1);
	astEnumConst = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astEnumConst, xNAMESPACE_ORD );
	stSymbolInfoAccess.name.set( astEnumConst, name );
	stSymbolInfoAccess.kind.set( astEnumConst, SYMBOL_KIND_ENUMCONST );
	return astEnumConst;
}
AST CcSymNewFunction( PSZ name ){
	AST  astFunction=0;
	stSymbolInfoAccess.alloc(1);
	astFunction = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astFunction, xNAMESPACE_ORD );
	stSymbolInfoAccess.name.set( astFunction, name );
	stSymbolInfoAccess.kind.set( astFunction, SYMBOL_KIND_FUNCTION );

	return astFunction;
}
AST CcSymNewVariable( PSZ name ){
	AST  astVariable=0;
	stSymbolInfoAccess.alloc(1);
	astVariable = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.nameSpace.set( astVariable, xNAMESPACE_ORD );
	stSymbolInfoAccess.name.set( astVariable, name );
	stSymbolInfoAccess.kind.set( astVariable, SYMBOL_KIND_VARIABLE );

	return astVariable;
}
VOID CcSymSetToFunction( AST astSym ){
	stSymbolInfoAccess.nameSpace.set( astSym, xNAMESPACE_ORD );
	stSymbolInfoAccess.kind.set( astSym, SYMBOL_KIND_FUNCTION );
}
VOID CcSymSetToVariable( AST astSym ){
	stSymbolInfoAccess.nameSpace.set( astSym, xNAMESPACE_ORD );
	stSymbolInfoAccess.kind.set( astSym, SYMBOL_KIND_VARIABLE );
}
VOID CcSymSetToTypedefId( AST astSym ){
	stSymbolInfoAccess.nameSpace.set( astSym, xNAMESPACE_ORD );
	stSymbolInfoAccess.kind.set( astSym, SYMBOL_KIND_TYPEDEFID );
}
AST CcSymNewUnknown( PSZ name ){
	AST  astSym=0;
	stSymbolInfoAccess.alloc(1);
	astSym = stSymbolInfoAccess.getMax();
	stSymbolInfoAccess.name.set( astSym, name );
	return astSym;
}
VOID CcSymCopy( AST astOrg, AST astDst ){
	stSymbolInfoAccess.copy( astOrg, astDst, 1 );
}
